/**
 *@author CEZERYE
 *@since 03.10.2011
 */
package controller;


import model.Activity;
import model.Inventory;
import model.Project;
import model.Resource;
import model.Task;
/**
 * this class adds Project,Activity and Task,
 *additionally also control start dates of each one.
 */
public class Controller {
	
	//private  HumanResources oHumanResources = new HumanResources();
	
	/**
	 * addProjectFromMenu() this method is adds project can be selected from menu
	 * @param name            project's name can be selected from menu
	 * @param description     project's description can be selected from menu
	 * @param startDate       project's start date can be selected from menu
	 * @param pManager        project manager of project can be selected from menu
	 * @return  myProject
	 */


//	public Project addProjectFromMenu(String name, String description, String startDate,int pManagerId){
//			return oHumanResources.addProject(name, description, startDate,pManagerId);
//	}
//	
//	
//	public void removeProjectFromMenu(int pId){
//		
//	}
//	
//	public Project updateProjectFromMenu(){
//		return null;
		
//	}
	/*This method controls the dates of project and its activities.Activities' start dates must 
	be after from projects.If it is not,all values of objects of type activity are set to null. */
//	public boolean controlProjectActivityDates(Date actStartDate,Project project){
//		Calendar cal1=Calendar.getInstance();
//		Calendar cal2=Calendar.getInstance();
//		cal1.setTime(actStartDate);
//		cal2.setTime(project.getStartDate());
//		return cal1.after(cal2);		
//	}
//
//	/*This method controls the dates of acitivity and its tasks.Activities' start dates must 
//	be before than tasks.If it is not,all values of objects of type task are set to null. */
//	public boolean controlActivityTaskDates(Date taskStartDate,Activity activity){
//		Calendar cal1=Calendar.getInstance();
//		Calendar cal2=Calendar.getInstance();
//		cal1.setTime(taskStartDate);
//		cal2.setTime(activity.getStartDate());
//		return cal1.after(cal2);		
//	}
	/**
	 * addActivityFromMenu() this method is adds activity can be selected from menu
	 * @param desc              activity's description can be selected from menu
	 * @param startDate         activity's start date can be selected from menu
	 * @param deliverable       activity's deliverable can be selected from menu
	 * @param project           project contains the activity can be selected from menu
	 * @return myActivity
	 */

public Activity addActivityFromMenu(String desc, String startDate,String deliverable, Project project){
		
		//if(controlProjectActivityDates(startDate,project)){
		return project.addActivity( desc, startDate,deliverable);
		
		}
//		else {
//			System.out.println("Start date of activity must be after than project");		
//			return null;
//		}
		
	//}

public void removeActivityFromMenu(int actId){
	
}

public Activity updateActivityFromMenu(){
	return null;
	
}
/**
 * addTaskFromMenu() this method is adds tasks can be selected from menu
 * @param description         task's description can be selected from menu
 * @param startDate           task's start date can be selected from menu
 * @param estimatedHours      task's estimated hours can be selected from menu
 * @param deliverable         task's deliverable can be selected from menu
 * @param activity            task's activity can be selected from menu
 * @return myTask
 */
	
	public Task addTaskFromMenu(String description,String startDate, Integer estimatedHours, String deliverable, Activity activity){
		
		return activity.addTask(description, startDate, estimatedHours, deliverable);
		
	}
	
	public void removeTaskFromMenu(int taskId){
		
	}
	
	public Task updateTaskFromMenu(){
		return null;
		
	}
	/**
	 * addResourceFromMenu() this method is adds resources can be selected from menu
	 * @param number       resources's number can be selected from menu
	 * @param task
	 * @return  myResource
	 */
	public Resource assignResourceFromMenu(int number, Task task){
		
		Inventory myInventory = new Inventory();
		String resourceName = myInventory.getAllResourcesList().get(number).getName();
		return task.assignResourceToTask(number,resourceName);
	}
	
	public Resource unassignResourceFromMenu(){
		return null;
		
	}

}
